<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">
       
        <h:panelGroup rendered="true" >
            <h:form>
                <p:panel id="panelPrint" header="Casheir Staff Payment Detail">

                    <f:facet name="header" >
                        <p:outputLabel value="Casheir Staff Payment Detail"/>
                        <p:commandButton value="Refresh" ajax="false"  styleClass="noPrintButton" style="float: right;" actionListener="#{commonReport.recreteModal()}" />

                        <p:commandButton ajax="false" value="Print"  styleClass="noPrintButton" style="float: right;" >
                            <p:printer target="panelPrint" />
                        </p:commandButton>  

                        <p:commandButton ajax="false" value="Excel"  styleClass="noPrintButton" style="float: right;" >
                            <p:dataExporter type="xls" target="panelPrint" fileName="Casheir Staff Payment Detail" />
                        </p:commandButton>  

                        <p:panelGrid columns="4" style="min-width: 100%;">
                            <h:outputLabel value="From Date"/>
                            <p:calendar id="frmDate" value="#{commonReport.fromDate}" navigator="true"  pattern="dd MMMM yyyy HH:mm:ss" >
                            </p:calendar>

                            <h:outputLabel value="To Date"/>
                            <p:calendar id="toDate" value="#{commonReport.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss" >
                            </p:calendar>
                        </p:panelGrid>       
                        <p:panelGrid columns="2" style="min-width: 100%;">
                            <h:outputLabel value="Select Cashier : "/>
                            <p:autoComplete id="acNewPtArea" converter="webUs" completeMethod="#{webUserController.completeUser}"
                                            var="pta"  itemLabel="#{pta.code}" itemValue="#{pta}" forceSelection="true" value="#{commonReport.webUser}" >
                          
                                <p:column>#{pta.code}</p:column>
                                <p:column>#{pta.webUserPerson.name}</p:column>
                            </p:autoComplete>
                        </p:panelGrid>

                    </f:facet>
                    <br/><br/>
                    <p:dataTable id="report4" value="#{commonReport.userPaymentBills}" var="b"  >
                        <f:facet name="header">  
                            Payments Bills 
                        </f:facet> 
                        <p:column headerText="Date" rendered="#{commonReport.fromDate ne commonReport.toDate}"  >
                            <h:outputLabel value="#{b.createdAt}" >
                                <f:convertDateTime pattern="dd MMMM yyyy"/>
                            </h:outputLabel>
                        </p:column>

                        <p:column headerText="Time" >
                            <h:outputLabel value="#{b.createdAt}" >
                                <f:convertDateTime pattern="hh:mm a"/>
                            </h:outputLabel>
                        </p:column>
                        <p:column headerText="Bill Id" >
                            #{b.insId}
                        </p:column>
                        <p:column headerText="Billed Institution" >
                            #{b.institution.name}
                        </p:column>
                        
                        <p:column headerText="Staff Name" >
                            #{b.staff.person.nameWithTitle}
                        </p:column>
                        <p:column headerText="Discount Amount" style="text-align: right; ">
                            #{b.discount}
                        </p:column>
                        <p:column headerText="Cash" style="text-align: right;" rendered="#{commonReport.paymentCashTot!=0.0}"  >
                            <h:outputLabel rendered="#{b.paymentMethod=='Cash'}" value="#{b.netTotal}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                            <h:outputLabel rendered="#{b.paymentMethod!='Cash'}" value="0.00"/>
                        </p:column>
                        <p:column headerText="Credit" style="text-align: right;" rendered="#{commonReport.paymentCreditTot!=0.0}">
                            <h:outputLabel rendered="#{b.paymentMethod=='Credit'}" value="#{b.netTotal}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                            <h:outputLabel rendered="#{b.paymentMethod!='Credit'}" value="0.00"/>
                        </p:column>
                        <p:column headerText="Credit Card" style="text-align: right;" rendered="#{commonReport.paymentCreditCardTotal!=0.0}">
                            <h:outputLabel rendered="#{b.paymentMethod=='Card'}" value="#{b.netTotal}" >
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                            <h:outputLabel rendered="#{b.paymentMethod!='Card'}" value="0.00"/>
                        </p:column>

                        <f:facet name="footer">  
                            <p:panelGrid columns="2">
                                <h:outputLabel value="Cash Total"/>
                                <h:outputLabel id="pCashTot" value="#{commonReport.paymentCashTot}"><f:convertNumber pattern="#,##0.00" /></h:outputLabel>
                                <h:outputLabel value="Credit Total"/>
                                <h:outputLabel id="pCreditTot" value="#{commonReport.paymentCreditTot}"><f:convertNumber pattern="#,##0.00" /></h:outputLabel>
                                <h:outputLabel value="CreditCard Total"/>
                                <h:outputLabel id="pCardTot" value="#{commonReport.paymentCreditCardTotal}"><f:convertNumber pattern="#,##0.00" /></h:outputLabel>
                            </p:panelGrid>

                        </f:facet>
                    </p:dataTable>

                </p:panel>
            </h:form>
        </h:panelGroup>
    </ui:define>

</ui:composition>
